// pages/write/write.js
const app = getApp()

Page({

  data: {
    name: '',
    question: '',
    answer: '',
    content: ''
  },

  onLoad: function (options) {
  
  },
  nameInput: function (e) {
    this.setData({
      name: e.detail.value
    });
  },

  questionInput: function (e) {
    this.setData({
      question: e.detail.value
    });
  },
  answerInput: function (e) {
    this.setData({
      answer: e.detail.value
    });
  },
  contentInput: function (e) {
    this.setData({
      content: e.detail.value
    });
  },
  send: function() {
    var self = this;
    this.setData({
      session: wx.getStorageSync('session')
    });

    wx.request({
      url: app.globalData.baseUrl + 'users/insert',
      data: self.data,
      method: 'POST',
      success: function(res) {
        if (res.data.code === '000000') {
          console.log('发送成功');
          wx.navigateBack({
            delta: 2
          })
        }
      }

    })
  }
})